Repository navigation
fix(lazurio): Buddy's window makes Buddy's project when the folder appeared after the startup - #253
immakermatty wants to merge 3 commits into
Conversation
…peared after the startup The shared server made Buddy's project only in its startup, and only when the Buddy folder already existed then. On a move from Buddy GEN3 to GEN4 the server restarts before Lazurio creates the folder, so the thread route answered no-project and the window waited forever (LazurioPlatform#1179). The thread route now makes Buddy's project with the startup's own ensureBuddyProjectIfPresent when it finds none and the folder exists, then finds the thread as before. A folder that is still absent answers no-project as before. Of two first visits at once, the folder's lock lets one bootstrap win and the other finds its project. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
agentrozjedemeai
left a comment
There was a problem hiding this comment.
Blocking: Please add and run the required real-app scenario proof for this web-reproducible bug: start without the Buddy folder, create it after server startup, and show the window failing on the base and opening on this head with vp run scenarios:prove. The focused test covers the resolver, but it does not verify the route and window together; the PR explicitly says that runtime and browser proof is missing. AGENTS.md requires this proof for a bug reproducible in the web client.
Non-blocking: I could not independently run the focused tests or check:changed because vp is unavailable in this review environment. The PR reports the focused tests passing and a pre-existing failure in check:changed; I could not independently verify those results.
— Pablo
… appears The scenario runs a managed Environment on its own dev stack: the Folder exists when its server starts, the Buddy folder is made once the server is up, and the page at Buddy's origin must open Buddy's thread with its composer instead of "Buddy is still being set up." (LazurioPlatform#1179). start-app.ts lends it the web stack it starts for every scenario, now startWebStack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
agentrozjedemeai
left a comment
There was a problem hiding this comment.
Blocking: Please bring the new scenario files into the fork overlay policy and make the required Server and web compatibility check pass. Its current run fails before testing because scripts/scenarios/buddy-window-opens-after-folder-appears.e2e.ts and scripts/scenarios/start-app.ts are not on the overlay allowlist: https://github.com/Lazurio/t3code/actions/runs/44958333013/job/137011325257. This check is required by the main ruleset.
The earlier request for a real-app base/head scenario is addressed by the added scenario and the reported proof. I inspected the scenario and evidence; I could not independently rerun the tests because vp is unavailable here, and did not independently run the browser proof.
— Pablo
…s untouched Fork CI refused the scenario commit: the overlay changed start-app.ts and added a scenario under scripts/, neither on the allowlist. The scenario now starts its managed stack itself with start-app.ts's own exports, start and prepareHome, so start-app.ts is upstream's again. The scenario file stays in scripts/scenarios/, the one folder e2e reads scenarios from and where their fixtures and dependencies resolve, and joins the allowlist with that reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
agentrozjedemeai
left a comment
There was a problem hiding this comment.
The overlay allowlist now includes the scenario and start-app.ts matches the base again. The previously failing overlay check step passes on this head; the full Server and web compatibility job is still running and must finish green before merge.
Non-blocking: I verified the allowlist locally and the diff has no whitespace errors. I could not independently rerun the scenario or release-contract tests: vp and the installed dependencies are absent here. The PR reports a successful base/head scenario proof.
— Pablo
What
On the shared Chat server (Buddy GEN4),
POST /api/lazurio/buddy/threadnow makes Buddy's project when it finds none over the declared Buddy folder and the folder exists now. It then finds or makes Buddy's thread as before, so the first window open after the folder appears gets the thread without a restart.Why
Lazurio/LazurioPlatform#1179. The server made Buddy's project only in its startup (
ensureManagedFolderProjectinmanagedFolderStartup.ts), and only when the Buddy folder already existed at that moment. When a Personal Environment moves from Buddy GEN3 to GEN4, the shared T3 Code restarts about 2 minutes before Lazurio creates~/Buddy. No project was made, the route answeredno-project, and Buddy's window showed "Buddy se teprve instaluje." until the next server restart.How
managedFolderStartup.tsexportsensureBuddyProjectIfPresent(buddyFolder): the startup's existing folder check plusensureBuddyProject(bootstrap titled Buddy, unarchive, restore Buddy's threads), returning whether the folder was there. The startup calls it in the same place, still inside thecatchCausethat keeps Buddy's part from stopping the Folder's Chat. Nothing was copied.buddySurfaceThread.ts:resolveSharedBuddyThreadgoes throughfindSharedBuddyThreadMakingProject. Onno-projectit callsensureBuddyProjectIfPresent. If the folder is absent it returns the originalno-projectunchanged. Otherwise it reads the project again and continues.buddySurfaceThreadRoute.tspasses the route layer'sProjectService,SecureRandomandFileSystemto the resolver. On the server these come from the runtime's guardedlayerProjectService, so the managed-folder guard still canonicalizes the Buddy folder path.Two first requests at once
projects.bootstrapreads by workspace root and then creates under a fresh randomcommandId, so thecommandIdalone does not deduplicate. What serializes it isProjectService.commit: it holds a per-workspace-rootKeyedLockand re-reads the active owner of the root inside the lock. The second create is rejected withProjectConflictError. The lazy path treats that failure as "someone else made it" and reads the project again, so both requests end with the same single project. The thread itself was already idempotent, because its id and command derive from the project id. This gives the same guarantee as the startup's path, since it uses the same function and lock, within one server process.Why only the thread route
findSharedBuddyThreadis also called bybuddySignal.ts(the signal read) andbuddySurfaceDays.ts(the days list). Both are read-only GETs and already treatno-projectas "no thread yet" (noThread/{ days: [] }). The thread POST is the one call that already writes, needs the orchestration operate scope, and is what Buddy's window waits on. Putting creation intosharedBuddyProjectwould turn those reads into writers that needProjectServicetoo, and fix nothing visible: once the window's POST has made the project, both reads find it. So the lazy creation sits inresolveSharedBuddyThreadonly.Tests
buddySurfaceThread.test.ts: the Buddy folder is absent whenensureManagedFolderProjectruns, then created. Two concurrentresolveBuddyThread()calls get the same result, there is exactly one project over the folder (titled Buddy, not archived), and it has one thread on the Lazurio project's model. This test fails onorigin/mainwithBuddyThreadUnavailable: no-project … is not in this T3 Code yet.no-projectcase now removes the Buddy folder first. It still assertsno-project, plusnot-buddywithout a declared folder, and that no project was made.buddySurface.testkit.tsgiveslayerBuddyServerthe runtime's reallayerProjectServiceover the same database. It usesmanagedFolder.testkit.ts's stubs for workspace paths and metadata, which are now exported.agentCli.test.ts's mocked route gets an emptyProjectServicemock.Commands, run from
apps/server:vp run typecheck: passes (exit 0).vp test run src/lazurio/buddySurfaceThread.test.ts src/lazurio/managedFolderStartup.test.ts src/lazurio/buddySignal.test.ts src/lazurio/buddySignalRead.test.ts src/lazurio/buddySurfaceDays.test.ts src/lazurio/buddySurfaceGuards.test.ts src/lazurio/buddyPrompt.orchestrator.test.ts src/lazurio/buddySteer.orchestrator.test.ts src/lazurio/agentCli.test.ts src/lazurio/managedFolder.test.ts src/lazurio/managedFolderGuards.test.ts: 11 files, 98 tests passed.From the repo root,
vp run check:changedpasses format, lint, knip, graphql and typecheck. In its test step,src/provider/AgentContextBudget.test.tsfails withcodexAdditionalContextBytesmeasured 8835 against a budget of 7324. It fails the same way withorigin/main's sources, and nothing in this diff touches model-facing text. It is a pre-existing failure, not caused by this change.Scenario proof in the real app
scripts/scenarios/buddy-window-opens-after-folder-appears.e2e.tsruns a managed Environment on its own loopback dev stack (real server, Vite web client, headless Chromium) with a temporary T3 home under the checkout's gitignored.t3.T3CODE_LAZURIO_FOLDERpoints to a folder that exists.T3CODE_LAZURIO_BUDDY_FOLDERpoints to a sibling folder that does not exist when the server starts.T3CODE_LAZURIO_BUDDY_ORIGINis the page's own origin, so the page is Buddy's window. Once the server has printed its pairing link (after the startup'slazurio.projectphase) and answers through Vite, the scenario creates the Buddy folder and opens the window. It then asserts that "Buddy is still being set up." is gone and that the composer is shown. The scenario gets its own stack because a managed Folder would change every other scenario's server.Where the scenario lives (Fork CI allowlist)
Fork CI lets the overlay change an upstream file under
apps/,packages/orscripts/only if the file is on theallowed_upstream_changesallowlist inlazurio-fork-ci.yml, or lies in the overlay's ownapps/*/src/lazurio/. The first version added the scenario underscripts/scenarios/and changedscripts/scenarios/start-app.tsto export astartWebStackhelper. Neither file was on the allowlist, so the check failed on9d04320525. Of the three ways out:start-app.tsis upstream's again, byte for byte. The scenario starts its stack itself with whatstart-app.tsalready exports (startandprepareHome), the way upstream'ssecond-server.tsstarts a second server.apps/server/src/lazurio/: not possible. e2e reads scenarios only fromscripts/e2e.config.ts'stests: "scenarios/**/*.e2e.ts". A scenario also importse2e,@e2e-dev/weband the fixtures (t3.ts,e2e.config.ts), which resolve only inside thescriptspackage. The runbook's rule for overlay tests (docs/operations/lazurio-fork-release.md: a test goes into its own test file or intoapps/*/src/lazurio/) has no place a scenario could run from.scripts/scenarios/buddy-window-opens-after-folder-appears.e2e.ts. It is a new file and changes no upstream code.Command, from the repo root:
The run on the current head exited 0 with verdict
Proven: the scenario fails on base 4a51029c1c and passes on head 2d30a1c31d.:4a51029c1c(origin/main): failed withASSERTION_FAILED: expect.toBeHidden … observed: visible (match count 1). The window stays at "Buddy is still being set up."2d30a1c31d: passed. The window opens Buddy's thread with the "Message Buddy…" composer.4a51029c1c2d30a1c31dThe captures are in a gist. They were uploaded from the earlier proof run on
9d04320525. The run on2d30a1c31dproduced byte-identical captures on both sides (checked withcmp), so the images stand for this head too. The tool's full output (proof.json,proof.md, the base failure capture and both videos) was written toscripts/.e2e/prove/of the run's checkout. That folder is gitignored and is not part of this PR.The allowlist step of Fork CI was also run locally. The same
git diff --name-onlypipeline overUPSTREAM_SHA..HEAD, with the workflow's own allowlist, passes.node --test scripts/lazurio-release-contract.test.mjspasses 56/56; it checks that the allowlist has only exact, existing, unique files.Not covered
Agent: environment a480495c-25e0-4e51-828b-1dbf1b77d62f · T3 thread d27e5511-ab1d-4892-a9a9-0ec9646d4834
🤖 Generated with Claude Code